from game import zz_player_data, zz_game_shengdian
from zz import zz_code

# img_src = './test.png'
#
big_enable_end_time = zz_code.date_add_second(zz_code.date_now(), 60)

print(big_enable_end_time > zz_code.date_now())

# list = zz_player_data.to_list('./player_data_0.json')
# list.append(zz_player_data.PlayerData())
# for item in list:
#     print(item.go, item.height, item.ack)
# b = zz_code.date_now()
# zz_img_cv.color_match(img_src, (38, 322))
# e = zz_code.date_now()
# print((e - b).microseconds / 1000)

# image = np.array(cv2.imread(img_src))
# print(image)
# print(image[322][38])

# img_arr = zz_img_cv.load_img(img_src)
# cv2.namedWindow("preview", cv2.WINDOW_NORMAL)
#
# # src_w, src_h = img_arr.shape[::-1]
# # cv2.resizeWindow("preview", src_w, src_h)
# cv2.imshow("preview", img_arr)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
# print(img_arr)
# print(isinstance(img_arr, np.ndarray))
# # r = zz_img_cv.find_img(img_arr, './game/img/player.png')
# # print(r.to_json())
# from typing import List
#
# a = (100, 50)
# b = [100, 50]
# print(a[0])
# print(b[0])
# print(a == b)
# print(isinstance(a, tuple))


# print(zz_game.get_tmp_file())


# def get_rack_coordinates(img_src, p1, p2):
#     img_src = zz_img_cv.load_img(img_src)
#
#     # 获取矩形的左下角和右上角坐标
#     left, bottom = min(p1[0], p2[0]), min(p1[1], p2[1])
#     right, top = max(p1[0], p2[0]), max(p1[1], p2[1])
#
#     # 生成所有坐标
#     p_arr = []
#     for y in range(bottom, top + 1):
#         for x in range(left, right + 1):
#             bgr = img_src[y][x]
#             print(f"x,y = {x},{y}; rgb = {bgr}")
#             p_arr.append(bgr)
#     return p_arr

#
# img_src = zz_img_cv.load_img('./test.png')
# img_src = img_src[:, :, [2, 1, 0]]  # bgr 转 rgb [255   8   7   7]
# print(img_src)
# p_arr = get_rack_coordinates(img_src, (1, 1), (2, 2))
# print(p_arr)

# a1 = np.arange(0, 10, 1)
# a2 = np.arange(5, 10, 1)
# a1 = np.array(a1)
# a2 = np.array(a2)
# print(a1, a2)
# positions = np.where((a1 == 10).all())
# print(positions)

# 示例数组
# a = np.array([[[8, 7, 7], [8, 7, 7], [8, 7, 7]], [[3, 4, 6], [2, 5, 6], [2, 4, 6]]])
# b = np.array([[2, 4, 6], [8, 9, 7]])
#
# threshold = 5
# next_color = [(181, 159, 150)]
# next_color_next = []
#
# for rgb in next_color:
#     r, g, b = rgb
#     next_color_next.append(rgb)
#     [next_color_next.append((r - i, g, b)) for i in range(1, threshold + 1)]
#     [next_color_next.append((r + i, g, b)) for i in range(1, threshold + 1)]
#
#     [next_color_next.append((r, g - i, b)) for i in range(1, threshold + 1)]
#     [next_color_next.append((r, g + i, b)) for i in range(1, threshold + 1)]
#
#     [next_color_next.append((r, g, b - i)) for i in range(1, threshold + 1)]
#     [next_color_next.append((r, g, b + i)) for i in range(1, threshold + 1)]
#
# print(next_color_next)
# print(len(next_color_next))
# threshold = 5
# c = []
#
# for rbg in b:
#     ([i - threshold for i in rbg] + [i + threshold for i in rbg])

# # 使用 np.isin 检查 a 中的元素是否在 b 中
# condition = np.isin(a, b).all(axis=2)
# print(condition)
# # 使用 np.where 获取满足条件的下标
# row_indices = np.where(condition)
# print(row_indices)
# row_x, row_y = row_indices
# coordinates = list(zip(row_x, row_y))
# print(coordinates)

# 初始化一个空列表来存储满足条件的下标
# matching_indices = []
# # 遍历 b 中的每个子数组
# for i, sub_b in enumerate(b):
#     # 检查 a 中的每个子数组是否等于 sub_b
#     for y in range(a.shape[0]):
#         for x in range(a.shape[1]):
#             if np.array_equal(a[y, x], sub_b):
#                 matching_indices.append((x, y))
# print(a.shape[1])
# print(matching_indices)

# zz_img_cv.color_match('./test.png', (1, 1), (5, 5), [[100, 120, 8]])
# a = (0, 0)
# b = (0, 0)
# print(a == b)

# a = {
#     "first": [123, 3],
#     "end": [111, 200]
# }
# print(a)
